  $(document).ready(function () {
		userInfoGetOne();
		$("#user-email").blur(function(){
		    if($(this).val()==null){
		        $("#user-email_msg").html("邮箱不能为空");
		    }else{
		        var $reg=/^[a-zA-Z1-9]\w{1,}@[a-zA-Z1-9]{2,}(\.(com|cn|net)){1,2}$/;
		        if(!$reg.test($("#user-email").val())){
		            $("#user-email_msg").html("邮箱格式错误！").css("color","red");
		        }else{
		            $("#user-email_msg").html("");
		        }
		    }
		});
	$('#file').on('change',function(){//图片上传
		var formData = new FormData;
		var file = document.getElementById("file").files[0];
		formData.append("file",file);
		formData.append("userId",localStorage.getItem(userId));
		$.ajax({
			type: 'post',
			url: server_url + '/profilePhotoUpload',
			data: formData,
			dataType: "json",
			cache: false,
			processData: false,
			contentType: false,
			success: function(data){
				if (msg.success == '0') {
					localStorage.setItem(photo,msg.data);
					window.location.reload();
				}
			}
	});
	
	})
	$("#save").on('click',function(){
		var sex=$("input[name='sex']:checked").val();
		
		var userInfoVo = {
			'nickname': $("#user-name2").val(),
			'userId':localStorage.getItem(userId),
			'sex':sex,
			'email':$("#user-email").val()
		}
	
		$.post(server_url + "/updateUserInfo", userInfoVo, function(msg) {
		if (msg.success == '0') {
			localStorage.setItem(photo,msg.data.image);
			window.location.reload();
		}
			});
	});


function userInfoGetOne(){
	var userVo = {
		'username': localStorage.getItem(username),
		'password': localStorage.getItem(password),
		'token': localStorage.getItem(satoken)
	}
	$.post(server_url + "/userInfoGetOne", userVo, function(msg) {
	if (msg.success == '0') {
		localStorage.setItem(userId,msg.data.userId);
		$("#user-name2").val(msg.data.nickname);
		$("#userphoto").attr("src",msg.data.image);
		localStorage.setItem(photo,msg.data.image);
		$("#user-email").val(msg.data.email);
		if(msg.data.sex==1){
		  // $("#isFeMale").removeAttr("checked");
		  $("#isMale").attr("checked","checked");
		}
		else{
			// $("#isMale").removeAttr("checked");
			$("#isFeMale").attr("checked","checked");
		}
	}
	});
}

	});